package com.aaa.sbm.controller;

import com.aaa.sbm.entity.StockOutDetail;
import com.aaa.sbm.service.StockOutService;
import com.aaa.sbm.util.Page;
import com.aaa.sbm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("stockOut")
public class StockOutController {

    @Resource
    private StockOutService stockOutService;

    @GetMapping("")
    public String index() {
        return "html/stocke";
    }

    @RequestMapping("insertSatockOut")
    public Result insertSatockIn(@RequestBody StockOutDetail stockOutDetail) {
        return stockOutService.insertStockOutDetailIn(stockOutDetail);
    }

    @PostMapping("list")
    public Result list(@RequestBody(required = false)Page<StockOutDetail> stockOutDetail) {
        return stockOutService.getStockList(stockOutDetail);
    }

    @PutMapping("update")
    public Result update(@RequestBody(required = false) StockOutDetail stockOutDetail) {
        return stockOutService.updateStockOut(stockOutDetail);
    }

    @GetMapping("delete/{outId}")
    public Result delete(@PathVariable Integer outId) {
        return stockOutService.deleteStockOut(outId);
    }

    @PutMapping("/batch")
    public Result batchStockIn(@RequestBody List<Integer> outIds) {
        return stockOutService.batchStockOut(outIds);
    }
}
